<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="./js/ctx.js"></script>
</head>
<body>
<div id="cesiumContainer">
</div>
<script>
    var initCesium = new InitCesium();
    var viewer = initCesium.initViewer('cesiumContainer',{
        shouldAnimate : true
    });

    function dataCallback(interval, index) {
        var time;
        if (index === 0) { // leading
            time = Cesium.JulianDate.toIso8601(interval.stop);
        } else {
            time = Cesium.JulianDate.toIso8601(interval.start);
        }

        return {
            Time: time
        };
    }

    var times = Cesium.TimeIntervalCollection.fromIso8601({
        iso8601: '2015-07-30/2017-06-16/P1D',
        leadingInterval: true,
        trailingInterval: true,
        isStopIncluded: false, // We want stop time to be part of the trailing interval
        dataCallback: dataCallback
    });

    // Add a WMTS imagery layer
    var provider = new Cesium.WebMapTileServiceImageryProvider({
        url : 'https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/AMSR2_Snow_Water_Equivalent/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png',
        layer : 'AMSR2_Snow_Water_Equivalent',
        style : 'default',
        tileMatrixSetID : '2km',
        maximumLevel : 5,
        format : 'image/png',
        clock: viewer.clock,
        times: times,
        credit : 'NASA Global Imagery Browse Services for EOSDIS'
    });
    var imageryLayers = viewer.imageryLayers;
    imageryLayers.addImageryProvider(provider);
    provider.readyPromise
            .then(function() {
                var start = Cesium.JulianDate.fromIso8601('2015-07-30');
                var stop = Cesium.JulianDate.fromIso8601('2017-06-17');

                viewer.timeline.zoomTo(start, stop);

                var clock = viewer.clock;
                clock.startTime = start;
                clock.stopTime = stop;
                clock.currentTime = start;
                clock.clockRange = Cesium.ClockRange.LOOP_STOP;
                clock.multiplier = 86400;
            });

</script>
</body>
</html>